#ifndef ENGINE_H
#define ENGINE_H

#include <cstdlib>

#include <QObject>
#include <QTimer>

#include "fmod.hpp"
#include "fmod_event.h"

class Game;
class Ui;
class View;
class Scene;

class Engine : public QObject
{
public:
    ~Engine();

    static Engine& instance();

    FMOD_EVENTSYSTEM* fmod() const;
    Game& game() const;
    Ui& ui() const;
    View& view() const;
    Scene& scene() const;

    void initialize();
    void start();
    void stop();

    //------------------------------------------------
    //  Attributes.
    //------------------------------------------------
    static const qreal s_updateDelay = 0.033;

protected:
    Engine(QObject* pkParent = NULL);

    Engine(const Engine&);
    Engine& operator = (const Engine&);

private:
    //------------------------------------------------
    //  Attributes.
    //------------------------------------------------
    // Engine instance.
    static Engine*        s_pkInstance;

    // Timer.
    QTimer                m_kTimer;

    // FMOD.
    FMOD_EVENTSYSTEM*     m_pkFMODEventSystem;
    FMOD_EVENTGROUP*      m_pkFMODEventGroup;

    // Core.
    Game*                 m_pkGame;
    Ui*                   m_pkUi;
    View*                 m_pkView;
    Scene*                m_pkScene;
};

#endif // ENGINE_H
